import absSubAction from "../abssubcmdaction";
import globalConst from "../../../canvas/common/globalConst.js";
var global = globalConst.GlobalConst;
import {LGXEnums}  from "../../../canvas/common/sysenum";


var RotateCommVar = {}

RotateCommVar.CurentMode = LGXEnums.EditMode.rotate;
RotateCommVar.unstart = "unstart";
RotateCommVar.center = "center";
RotateCommVar.pickRotStartPoint = "pickRotStartPoint";
RotateCommVar.pickRotDestPoint = "pickRotDestPoint";
RotateCommVar.finish = "finish";
import cmdenums from "../cmdenums";

class RotateEditAction extends absSubAction.AbsSubAction {
    constructor() {
        super();
        this.mainCMD = cmdenums.EditCmdType.rotate;
    }

    actCanvasEvt(evt, mainctl) {
        let actRst = null;
        let coordDecs = evt.wx.toFixed(2) + "," + evt.wy.toFixed(2);
        if (evt.subEditModeState == RotateCommVar.center) {
            let cmd = new absSubAction.TCmd();
            cmd.type = 'edit_lmousedown';
            cmd.value = "";
            let nextTips = "输入旋转角度（逆时针为正）或鼠标左键按下或输入确定旋转基点坐标（x,y），相对坐标（@x,y）。取消（Esc）。";
            let appendToPreCMD = coordDecs;
            actRst = { cmdObj: cmd, nextTips, appendToPreCMD };
        }
        else if (evt.subEditModeState == RotateCommVar.pickRotStartPoint){
            let cmd = new absSubAction.TCmd();
            cmd.type = 'edit_lmousedown';
            cmd.value = "";
            let nextTips = "输入旋转角度（逆时针为正）或鼠标左键按下或输入确定旋转目标线坐标点（x,y）,相对坐标（@x,y）取消（Esc）。使用当前位置直接回车(e)";
            let appendToPreCMD = coordDecs;
            actRst = { cmdObj: cmd, nextTips, appendToPreCMD };
        }
        else if (evt.subEditModeState == RotateCommVar.pickRotDestPoint
            ||evt.subEditModeState == RotateCommVar.finish) {
            let cmd = new absSubAction.TCmd();
            cmd.type = 'end';
            cmd.value = "";
            let nextTips = "取消（Esc）。删除原图？（Y/N）";
            let appendToPreCMD = coordDecs;
            actRst = { cmdObj: cmd, nextTips, appendToPreCMD };
        }
        return actRst;
    }
}

export default { RotateEditAction }